from celery.schedules import crontab
from celery import Celery

app = Celery('two',  broker='redis://localhost:6379/3',backend='redis://localhost:6379/3')

# 每一分钟执行一次
app.conf.beat_schedule = {
    'add-every-5-seconds': {
        'task': 'task.generate_report',
        'schedule': 5.0,
        'args': (),
    }
}

# 定义定时任务
@app.task
def generate_report():
    """生成每日报表任务"""
    import datetime
    print(f"生成报表时间：{datetime.datetime.now()}")
    # 这里编写报表生成逻辑